package com.weimob.mcloud.wechatwork.customer.service.user.enums.sidebar;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * 营销活动类型枚举
 *
 * @author WEIMOB
 * @version 1.0
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum CampaignTypeEnum {

    /**
     *
     */
    FULL_DISCOUNT(1, null, "满减满折", "ec-fulldiscount-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    FREE_FREIGHT(2, null, "满减邮", "ec-freefreight-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    DISCOUNT(3, null, "限时折扣", "ec-discount-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    PRIVILEGE_PRICE(10, 1001, "特权价", "ec-teprivilegeprice-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    ENTERPRISE_BUY(10, 1002, "企业内购", "ec-qiprivilegeprice-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    NYNJ(12, null, "N元N件", "ec-nynj-home", 145L,CampaignCategoryEnum.SALES_PROMOTION),

    CHANGELESS(13, 1301, "固定套装", "ec-gucombination-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    MATCH_BUY(13, 1302, "搭配套装", "ec-dacombination-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    SINGLE_REDEMPTION(14, 1401, "单品换购", "ec-danredemption-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    ORDER_REDEMPTION(14, 1402, "订单换购", "ec-dingredemption-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    LIMIT_QUANTITY(20, null, "限量抢购", "ec-limitquantity-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    DEPOSIT_EXPANSION(24, null, "定金膨胀", "ec-depositexpansion-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    GRADED_PRICE(25, null, "阶梯价", "ec-gradedprice-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    GIFT_MARKETING(32, null, "满赠", "ec-giftmarketing-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    XJXZ(37, null, "第X件X折", "ec-xjxz-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    FISSION_SHOPPING(41, null, "裂变内购", "ec-fissionshopping-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    ITEM_PRICE(42, null, "一口价", "ec-itemprice-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),

    BUY_M_PAY_N(51, null, "买M付N", "ec-buynpayn-home", 145L, CampaignCategoryEnum.SALES_PROMOTION),


    ;


    /**
     * 活动主类型
     */
    private Integer activityType;

    /**
     * 活动子类型
     */
    private Integer activitySubType;

    /**
     * 活动名称
     */
    private String activityName;

    /**
     * 活动对应refer
     */
    private String refer;

    /**
     * 产品id
     */
    private Long productId;

    /**
     * 所属分类
     */
    private CampaignCategoryEnum campaignCategoryEnum;

    /**
     * 根据refer查询对应的枚举
     *
     * @param refer
     * @return
     */
    public static CampaignTypeEnum valueOfRefer(String refer, Long productId) {
        for (CampaignTypeEnum campaignTypeEnum : CampaignTypeEnum.values()) {
            if (Objects.equals(campaignTypeEnum.getRefer(), refer) && Objects.equals(campaignTypeEnum.getProductId(),  productId)) {
                return campaignTypeEnum;
            }
        }
        return null;
    }


}
